home *** CD-ROM | disk | FTP | other *** search
- #slipdial
- #--------------------------------------------------------------------
- # Script for calling {{net_provider_name}}
- #
- # Credits: original R.W. Orwin 1994 (rob@wong.demon.co.uk)
- # sprites James Woodman (woody@bacchus.demon.co.uk)
- # new version Alan Fitch (alan@cycle.demon.co.uk)
- # mercury improvements Mike James (mike@hamble.demon.co.uk)
- # improved setting up Doug Macready (dougmac@newquay.zynet.co.uk)
- # Adapted for NetConfig Colin Hogben (colin@nyphot.demon.co.uk)
-
- call initMain
- call configure
- call setserial
- call makemenus
-
- #
- # main loop
- #
-
- :loop
- message /close
- wait /event
- goto loop
- exit
-
- # end of program
- #--------------------------------------------------------------------
-
- #====================================================================
- # SUBROUTINES
- #====================================================================
-
- # dial number 1 from the configuration file
- :dial1
- set nRetries 50
- set phonenum %phonenum1
- if (?ne %phonenum1 %nopredialnum) set phonenum %predial%phonenum1
- goto dodial
-
- # dial number 2 from the configuration file
- :dial2
- set nRetries 50
- set phonenum %phonenum2
- if (?ne %phonenum2 %nopredialnum) set phonenum %predial%phonenum2
- goto dodial
-
- # dial number 3 from the configuration file
- :dial3
- set nRetries 50
- set phonenum %phonenum3
- if (?ne %phonenum3 %nopredialnum) set phonenum %predial%phonenum3
- goto dodial
-
- # dial the number defined as local
- :diallocal
- set nRetries 50
- set phonenum %localnumber
- if (?ne %localnumber %nopredialnum) set phonenum %predial%localnumber
- goto dodial
-
- #-----------------------------------------------------------
- # Subroutine: List
- # Calls a list of phone numbers, specified below in the
- # variable 'phonenum'. Returns via subroutine dodial.
- # nRetries is the number of times SlipDial retries the number
- # if it is busy.
- # The number of retries is reduced compared to the other
- # menu items (which dial only one PoP) as the intention is to
- # to work through the list of numbers reasonably quickly.
- #-----------------------------------------------------------
-
- :List
- set nRetries 5
- set phonenum %phonenum1
- if (?ne %phonenum1 %nopredialnum) set phonenum %predial%phonenum1
- if (?ne %phonenum2 %nopredialnum) set phonenum "%phonenum %predial"
- set phonenum "%phonenum%phonenum2"
- if (?ne %phonenum3 %nopredialnum) set phonenum "%phonenum %predial"
- set phonenum "%phonenum%phonenum3"
- goto dodial
-
- #-----------------------------------------------------------
- # Subroutine: dodial
- # Note: has multiple entry points from "goto" statements
- # above. However it finally returns to the main waiting
- # loop.
- #-----------------------------------------------------------
-
- :dodial
-
- #
- # kill newsbase and ttfn if they are running, and were started from SlipDial
- #
- # Note that if they weren't started by SlipDial, SlipDial knows nothing
- # about them and will start another copy even if they are already running.
- #
-
- task /kill="Newsbase"
- task /kill="TTFN"
-
- # Claim the device driver
-
- if (!claim 3) return 0
-
- # initialise modem
-
- if (! init) goto no_init
-
- # Do we have a password? If not then prompt for it.
- if (?ne "%password" "") goto havepass
- :getpass
- input /prompt="Password:" /hide password
- if (?eq "%password" "") goto getpass
- #endif
- :havepass
-
- # dial the number, return to main menu if failed.
-
- retry %nRetries 15
- if (!dial {{pulse}} /nodial=5 /nocar=3 /busy=3 %phonenum) return 0
-
- #
- # arrive here if dial succeeded
- # get username/password prompts to authenticate self to server.
- # after each prompt, return to main menu if failed.
- #
-
- @if net_slip_login_file$>""
- @include net_respath$+net_slip_login_file$
- @else
- if (!wait /del=50 {{net_login_prompt}}) goto no_login
- send %nodename
-
- if (!wait /del=20 {{net_password_prompt}}) goto no_password
- send %password
-
- @if net_protocol_prompt$>""
- if (!wait /del=50 {{net_protocol_prompt}}) goto no_protocol
- send {{net_protocol_reply}}
-
- @endif
- @if net_startup_prompt$>""
- message /capture /end="{{net_startup_prompt}}" /maxlines=7 /centre
- @if net_fixed_ip$=""
- ipget {{net_ip_prefix}}
- @endif
- if (!wait /del=30 {{net_startup_prompt}}) goto no_start
-
- @endif
- pause 5
- @endif
-
- @if net_fixed_ip$=""
- make slipdial:Domain <TCPIP$Dir>.Domain
- oscli "SetType <TCPIP$Dir>.Domain Text"
- oscli "Set TCPIP$String$ip_addr %ipaddress"
- @endif
- task /name="TCP/IP" <TCPIP2$dir>.!Run
-
- # watch out for carrier detect to go low
-
- alarm /dcd "goto good_finish"
- :loop2
- wait /event
- goto loop2
-
- #
- # Call has been finished successfully, so release the port
- #
-
- :good_finish
- task /kill="TCP/IP"
- message /close
- message "Call finished successfully" /centre
- release
-
- # now pause for 2 seconds to allow RISC OS to sort out the display.
-
- pause 2
-
- #
- # Start up TTFN and Newsbase.
- #
-
- if (!?task TTFN) task /name="TTFN" <TTFN$Dir>.!Run
- if (!?task NewsBase) task /name="Newsbase" <NewsBase$Dir>.!Run
- return 1
-
- #
- # Call failed in some way
- #
-
- :no_dsr
- message/wait "Modem not ready - DSR line is not set" "(Please close this window to continue)" /centre
- goto bad_finish
-
- :no_cts
- message/wait "Modem not ready - CTS line is not set" "(Please close this window to continue)" /centre
- goto bad_finish
-
- :no_init
- message/wait "Modem initialisation failed" "(Please close this window to continue)" /centre
- goto bad_finish
-
- :no_login
- message "Call failed - timeout waiting for login prompt" /centre
- goto bad_finish
-
- :no_password
- message "Call failed - timeout waiting for password prompt" /centre
- goto bad_finish
-
- :no_protocol
- message "Call failed - timeout waiting for protocol prompt" /centre
- goto bad_finish
-
- :no_start
- message "Call failed - timeout waiting for session start" /centre
- goto bad_finish
-
- :bad_finish
- pause 1
- release
- reinit
- return 0
-
- #-----------------------------------------------------------
- # Subroutine: makemenus
- # Defines the menus for dialling etc. Note the length of
- # all the names must be less than 255 characters total, as
- # must the length of all the commands.
- #-----------------------------------------------------------
-
- :makemenus
- @if net_pop3$>""
- menu "%name1:call dial1" "%name2:call dial2" "%name3: call dial3" "List:call List"
- @elseif net_pop2$>""
- menu "%name1:call dial1" "%name2:call dial2" "List:call List"
- @else
- menu "%name1:call dial1"
- @endif
- menu /icon="Local" "Local call:call diallocal"
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: setserial
- # Set Serial Port/Driver Parameters
- #-----------------------------------------------------------
-
- :setserial
- driver %driver
- port %wport %prtnum
- speed %speed
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: setup1
- # Called to setup defaults if no configuration file present.
- #-----------------------------------------------------------
-
- :setup1
- input/prompt="Enter Serial Block Driver Name : " wport
- input/prompt="Enter Serial Port Number (if relevant) : " prtnum
- input/prompt="Enter Your Modem->Computer Speed (bps) : " speed
- input/prompt="Enter Your Account name : " nodename
- input/prompt="Enter Your Password : " password
- input/prompt="Enter Your Modem Driver Name (e.g. USR): " driver
- input/prompt="Enter Dial prefix e.g. Mercury PIN : " predial
- input/prompt="Enter NAME of main number e.g. London : " name1
- input/prompt="Enter NUMBER of main number e.g. 01813384848 : " phonenum1
- input/prompt="Enter NAME of 2nd number : " name2
- input/prompt="Enter NUMBER 2nd number : " phonenum2
- input/prompt="Enter NAME of 3rd number : " name3
- input/prompt="Enter NUMBER of 3rd number : " phonenum3
- input/prompt="Enter nearest NUMBER, e.g. 01813384848 : " localnumber
- input/prompt="Enter number to which dial prefix does not apply, e.g. 01813384848 : " nopredialnum
- :saveconfig
- set filename {?file/expand slipdial:NetConfg}
- open/id=conf/write %filename
- write/id=conf %wport
- write/id=conf %prtnum
- write/id=conf %speed
- write/id=conf %nodename
- write/id=conf %password
- write/id=conf %driver
- write/id=conf %predial
- write/id=conf %name1
- write/id=conf %phonenum1
- write/id=conf %name2
- write/id=conf %phonenum2
- write/id=conf %name3
- write/id=conf %phonenum3
- write/id=conf %localnumber
- write/id=conf %nopredialnum
- close/id=conf
- return 1
-
- #-----------------------------------------------------------
- # Subroutine: configure
- # This loads password config from file or prompts for data
- # to create file.
- #-----------------------------------------------------------
-
- :configure
- set filename {?file/expand slipdial:NetConfg}
- if (!?file %filename) call setup1
- open/read/id=conf/error="return" %filename
- read/id=conf/eof="goto closeconf" wport
- read/id=conf/eof="goto closeconf" prtnum
- read/id=conf/eof="goto closeconf" speed
- read/id=conf/eof="goto closeconf" nodename
- read/id=conf/eof="goto closeconf" password
- read/id=conf/eof="goto closeconf" driver
- read/id=conf/eof="goto closeconf" predial
- read/id=conf/eof="goto closeconf" name1
- read/id=conf/eof="goto closeconf" phonenum1
- read/id=conf/eof="goto closeconf" name2
- read/id=conf/eof="goto closeconf" phonenum2
- read/id=conf/eof="goto closeconf" name3
- read/id=conf/eof="goto closeconf" phonenum3
- read/id=conf/eof="goto closeconf" localnumber
- read/id=conf/eof="goto closeconf" nopredialnum
- :closeconf
- close/id=conf
- return
-
- #-----------------------------------------------------------
- # Subroutine: initMain
- # General initialisation.
- #-----------------------------------------------------------
-
- :initMain
-
- # remove comment from following line for tracing
-
- #trace "SlipDial:logoutput"
- debug 3
- icon /id="Local" /action="call diallocal" loc
- return 1
-
- # End of file
-